$(function () {
 // 进行校验
 let form = layui.form
 let layer = layui.layer
 form.verify({
  pass: [
   /^[\S]{6,12}$/,
   '密码必须6到12位，且不能出现空格'
  ],
  newpwd: function (value) {
   let oldPwd = $('[name=oldPwd]').val()
   if (oldPwd == value) {
    return '新密码不能与原密码相同'
   }
  },
  repwd: function (value) {
   let newPwd = $('[name=newPwd]').val()
   if (newPwd !== value) {
    return '两次输入的密码不相同'
   }
  }
 })

 // 修改密码确认提交
 $('#form-pwd').on('submit', function (e) {
  e.preventDefault()
  axios({
   method: 'POST',
   url: '/my/updatepwd',
   data: $(this).serialize(),
   headers: {
    Authorization: localStorage.getItem('token')
   }
  }).then(res => {
   // 判断
   console.log(res.data.data)
   if (res.data.status != 0) {
    return layer.msg(res.data.message)
   } layer.msg('密码修改成功')

  })
 })

})